from manim import *



class math1(MovingCameraScene):
    def construct(self):
        self.camera.background_color = BLACK  # 设置背景颜色
        self.camera.frame_width = 100  # 设置边框宽度
        self.camera.frame_height = 60  # 设置边框高度
        self.camera.pixel_height = 1080  # 设置像素高度
        self.camera.pixel_width = 1920  # 设置像素宽度
        self.camera.center = ORIGIN  # 设置中心点位置
        self.camera.scale_factor = 1.0  # 设置缩放因子
        #设置横线
        for i in range(60*2+1):       
            dot1=Dot([-500,5*(i-60),0]).set_opacity(0.5)
            dot2=Dot([500,5*(i-60),0]).set_opacity(0.5)
            if i==6:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
                
            else:
                line1=Line(dot1,dot2).set_color(WHITE).set_opacity(0.5)
               
            self.add(dot1,dot2,line1)
        #设置竖线
        for i in range(100*2+1):        
            dot3=Dot([(i-100)*5,-300,0]).set_opacity(0.5)
            dot4=Dot([(i-100)*5,300,0]).set_opacity(0.5)
            if i==10:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
                
            else:
                line2=Line(dot3,dot4).set_color(WHITE).set_opacity(0.5)
            self.add(dot3,dot4,line2)
        #设置三个点
        dot1 = Dot(radius=1, color=RED)  
        dot1.move_to([-47.5,27.5,0]) 
        dot2 = Dot(radius=1, color=YELLOW)  
        dot2.move_to([-42.5,27.5,0])  
        dot3 = Dot(radius=1, color=GREEN)  
        dot3.move_to([-37.5,27.5,0])
        
        #镜头跟进效果 
        self.camera.frame.save_state()
        #题目出现
        text = Tex(r"\text{(题1)设函数}$f\left( u,v\right) $\text{具有二阶连续偏导,函数}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-20,22,0])
        text2 = Tex(r"$g\left( x,y\right) =xy-f\left( \dfrac{y}{x},\dfrac{x}{y}\right) $\text{,求}"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([22,22,0])
        text1 = Tex(
                   r"$x^{2}\dfrac{\partial ^{2}g}{\partial x^{2}}+2xy\dfrac{\partial ^{2}g}{\partial x\partial y}+y^{2}\dfrac{\partial ^{2}g}{\partial y^{2}}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-30,14,0])
        
        self.play(Write(text),Write(text1),Write(text2))
        
        #镜头拉回
          #分析文本
        #text100=MarkupText("<b><i>分析/解：</i></b>",color=PINK).scale(5.0).move_to([-38,12.5,0])
        
        self.play(FadeIn(dot1),run_time=0.1)
        self.play(FadeIn(dot2),run_time=0.1)
        self.play(FadeIn(dot3),run_time=0.1)
       
        text30 = Tex(
                   r"$\dfrac{\partial g}{\partial x}=$",color=GREEN
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,5,0])
        text3 = Tex(
                   r"$y-\left[ f_{1}\cdot \left( \dfrac{y}{-x^{2}}\right) +f_{2}\cdot\left( \dfrac{1}{y}\right) \right] $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text30,RIGHT,buff=1)
        self.play(Write(text30))
        self.play(Create(text3),run_time=8)
        self.wait(0.5)
        text40 = Tex(
                   r"$\dfrac{\partial g}{\partial y}=$",color=GREEN
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,-10,0])
        text4 = Tex(
                   r"$x-\left[ f_{2}\cdot\left( \dfrac{x}{-y^{2}}\right) +f_{1}\cdot\left( \dfrac{1}{x}\right) \right] $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text40,RIGHT,buff=1)
        
        text5 = Tex(
                   r"$g\left( y,x\right) =xy-f\left( \dfrac{x}{y},\dfrac{y}{x}\right) $",color=GREEN
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([20,15,0])
        self.play(Write(text5))
        #框框
        rectangle=Rectangle(color=BLUE,fill_opacity=0.0,width=19,height=20
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle.move_to([25, 20, 0])
        self.play(Create(rectangle))
        rectangle1=Rectangle(color=BLUE,fill_opacity=0.0,width=2.5,height=6
                            ,stroke_color=RED,stroke_width=20)
        rectangle1.move_to([27.8, 22, 0])
        rectangle3=Rectangle(color=BLUE,fill_opacity=0.0,width=2.5,height=6
                            ,stroke_color=RED,stroke_width=20)
        rectangle3.move_to([27.8, 22, 0])
        self.play(Create(rectangle1),Create(rectangle3))
        rectangle2=Rectangle(color=BLUE,fill_opacity=0.0,width=2.5,height=6
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle2.move_to([31.3, 22, 0])
        rectangle4=Rectangle(color=BLUE,fill_opacity=0.0,width=2.5,height=6
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle4.move_to([31.3, 22, 0])
        self.play(Create(rectangle2),Create(rectangle4))
        #框框移动
        self.play(rectangle3.animate().move_to([31.5, 15, 0]),rectangle4.animate().move_to([28.2, 15, 0]))


        self.play(Write(text40))
        self.play(Write(text4))

        arrow = Arrow(start=[-35,2,0],end=[-35,-7,0],color=RED
                       , stroke_width=20, tip_length=1)
        arrow1 = Arrow(start=[-29,2,0],end=[-29,-7,0],color=BLUE
                       , stroke_width=20, tip_length=1)
        arrow2 = Arrow(start=[-22,2,0],end=[-22,-7,0],color=RED
                       , stroke_width=20, tip_length=1)
        arrow3 = Arrow(start=[-12.5,2,0],end=[-12.5,-7,0],color=BLUE
                       , stroke_width=20, tip_length=1)
        arrow4 = Arrow(start=[-7,2,0],end=[-7,-7,0],color=RED
                       , stroke_width=20, tip_length=1)
        self.play(GrowArrow(arrow),GrowArrow(arrow2),GrowArrow(arrow4))
        self.play(GrowArrow(arrow1),GrowArrow(arrow3))

        
        

        # 使用 updater 让子对象跟随父对象
        def update_child(mob):
            mob.next_to(text40,RIGHT,buff=1)
        
        text4.add_updater(update_child)


        self.play(FadeOut(arrow1),FadeOut(arrow3),FadeOut(arrow),FadeOut(arrow2),FadeOut(arrow4)
                  ,FadeOut(rectangle),FadeOut(rectangle1),FadeOut(rectangle2),FadeOut(rectangle3),FadeOut(rectangle4)
                  ,FadeOut(text5)
                  ,text40.animate().move_to([5, 5, 0]))
        
        text6 = Tex(
                   r"$\dfrac{\partial ^{2}g}{\partial x^{2}}=$",color=RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,-5,0])
        text7 = Tex(
                   r"$0-\left[ \dfrac{\partial f_{1}}{\partial x}\left( \dfrac{y}{-x^{2}}\right) +f_{1}\left( \dfrac{y}{-x^{2}}\right) ^{'}+\dfrac{\partial f_{2}}{\partial x}\left( \dfrac{1}{y}\right) \right] $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text6,RIGHT,buff=1)
        text8 = Tex(
                   r"\text{(宏观求导)}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text7,RIGHT,buff=1)
        self.play(Write(text6))
        self.play(Create(text7),run_time=2)
        self.play(Write(text8))


        rectangle5=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle5.move_to([-27.5, -5, 0])
        rectangle50=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle50.move_to([-27.5, -5, 0])
        
        rectangle6=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle6.move_to([-5, -5, 0])
        rectangle60=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle60.move_to([-5, -5, 0])
        
        rectangle7=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle7.move_to([5.5, -5, 0])
        rectangle70=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle70.move_to([5.5, -5, 0])
        self.play(Create(rectangle5),Create(rectangle6),Create(rectangle7),
                  Create(rectangle50),Create(rectangle60),Create(rectangle70))

        #框框丝滑变为文本
        text9 = Tex(
                   r"$\dfrac{\partial f_{1}}{\partial x}=$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,-15,0])
        self.play(
            ReplacementTransform(rectangle50,text9)
        )
        rectangle8=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle8.move_to([-28, 5, 0])
        
        text10 = Tex(
                   r"$f_{11}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text9,RIGHT,buff=1)
        self.play(Create(rectangle8))
        self.play(Write(text10))
        text11 = Tex(
                   r"$\cdot \left( \dfrac{y}{-x^{2}}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text10,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(6*RIGHT))
        self.play(Write(text11))


        text12 = Tex(
                   r"$+f_{12}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text11,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(10*RIGHT))
        self.play(Write(text12))



        text13 = Tex(
                   r"$\cdot \left( \dfrac{1}{y}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text12,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(5*RIGHT))
        self.play(Write(text13))
       
        text14 = Tex(
                   r"$\left( \dfrac{y}{-x^{2}}\right) ^{'}=\dfrac{2y}{x^{3}}$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-30,-24,0])
        self.play(
            ReplacementTransform(rectangle60,text14)
        )



        #框框丝滑变为文本
        text15 = Tex(
                   r"$\dfrac{\partial f_{2}}{\partial x}=$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])
        self.play(
            ReplacementTransform(rectangle70,text15)
        )

        self.play(rectangle8.animate().move_to([-28, 5, 0]))
        
        text16 = Tex(
                   r"$f_{21}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text15,RIGHT,buff=1)
       
        self.play(Write(text16))




        text17 = Tex(
                   r"$\cdot \left( \dfrac{y}{-x^{2}}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text16,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(6*RIGHT))
        self.play(Write(text17))


        text18 = Tex(
                   r"$+f_{22}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text17,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(10*RIGHT))
        self.play(Write(text18))



        text19 = Tex(
                   r"$\cdot \left( \dfrac{1}{y}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text18,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(5*RIGHT))
        self.play(Write(text19))
        self.wait(0.3)
        text20 = Tex(
                   r"$\dfrac{\partial ^{2}g}{\partial x^{2}}=-\dfrac{y^{2}}{x^{4}}f_{11}+\dfrac{2}{x^{2}}f_{12}-\dfrac{1}{y^{2}}f_{22}-\dfrac{2y}{x^{3}}f_{1}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-5,0])

        self.play(
            ReplacementTransform(rectangle8,text20),
            ReplacementTransform(rectangle5,text20),
            ReplacementTransform(rectangle6,text20),
            ReplacementTransform(rectangle7,text20),
            ReplacementTransform(text19,text20),
            ReplacementTransform(text18,text20),
            ReplacementTransform(text17,text20),
            ReplacementTransform(text16,text20),
            ReplacementTransform(text15,text20),
            ReplacementTransform(text14,text20),
            ReplacementTransform(text13,text20),
            ReplacementTransform(text12,text20),
            ReplacementTransform(text11,text20),
            ReplacementTransform(text10,text20),
            ReplacementTransform(text9,text20),
            ReplacementTransform(text8,text20),
            ReplacementTransform(text7,text20),
            ReplacementTransform(text6,text20),
            
        )

        text21 = Tex(
                   r"$x^{2}\dfrac{\partial ^{2}g}{\partial x^{2}}=-\dfrac{y^{2}}{x^{2}}f_{11}+2f_{12}-\dfrac{x^{2}}{y^{2}}f_{22}-\dfrac{2y}{x}f_{1}$",color=RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])

        self.play(Write(text21))
        self.play(text21.animate().scale(1).shift(UP*10),FadeOut(text20)) 
        self.play(self.camera.frame.animate.scale(1).shift(10*DOWN))
        ###########################################################################

        text6 = Tex(
                   r"$\dfrac{\partial ^{2}g}{\partial x\partial y}=$",color=GREEN
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,-15,0])
        text7 = Tex(
                   r"$1-\left[ \dfrac{\partial f_{1}}{\partial y}\left( \dfrac{y}{-x^{2}}\right) +f_{1}\left( \dfrac{y}{-x^{2}}\right) ^{'}+\dfrac{\partial f_{2}}{\partial y}\left( \dfrac{1}{y}\right) +f_{2}\left( \dfrac{1}{y}\right) ^{'}\right] $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text6,RIGHT,buff=1)
        text8 = Tex(
                   r"\text{(宏观求导)}",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text7,RIGHT,buff=1)
        self.play(Write(text6))
        self.play(Create(text7),run_time=2)
        self.play(Write(text8))


        rectangle5=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle5.move_to([-27.5, -15, 0])
        rectangle50=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle50.move_to([-27.5, -15, 0])
        
        rectangle6=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle6.move_to([-5, -15, 0])
        rectangle60=Rectangle(color=BLUE,fill_opacity=0.0,width=10,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle60.move_to([-5, -15, 0])
        
        rectangle7=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle7.move_to([5.5, -15, 0])
        rectangle70=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle70.move_to([5.5, -15, 0])

        rectangle9=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle9.move_to([23, -15, 0])
        rectangle90=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=BLUE,stroke_width=20)
        rectangle90.move_to([23, -15, 0])
        self.play(Create(rectangle5),Create(rectangle6),Create(rectangle7),Create(rectangle9),
                  Create(rectangle50),Create(rectangle60),Create(rectangle90),Create(rectangle70))

        #框框丝滑变为文本
        text9 = Tex(
                   r"$\dfrac{\partial f_{1}}{\partial y}=$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-40,-25,0])
        self.play(
            ReplacementTransform(rectangle50,text9)
        )
        rectangle8=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=10
                            ,stroke_color=YELLOW,stroke_width=20)
        rectangle8.move_to([16, 5, 0])
        
        text10 = Tex(
                   r"$f_{12}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text9,RIGHT,buff=1)
        self.play(Create(rectangle8))
        self.play(Write(text10))
        text11 = Tex(
                   r"$\cdot \left( \dfrac{x}{-y^{2}}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text10,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(6*RIGHT))
        self.play(Write(text11))


        text12 = Tex(
                   r"$+f_{11}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text11,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(10*RIGHT))
        self.play(Write(text12))



        text13 = Tex(
                   r"$\cdot \left( \dfrac{1}{x}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text12,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(5*RIGHT))
        self.play(Write(text13))
       
        text14 = Tex(
                   r"$\left( \dfrac{y}{-x^{2}}\right) ^{'}=-\dfrac{1}{x^{2}}$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([-30,-35,0])
        self.play(
            ReplacementTransform(rectangle60,text14)
        )
        text140 = Tex(
                   r"$\dfrac{-1}{y^{2}}$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([30,-35,0])
        self.play(
            ReplacementTransform(rectangle90,text140)
        )


        #框框丝滑变为文本
        text15 = Tex(
                   r"$\dfrac{\partial f_{2}}{\partial y}=$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-25,0])
        self.play(
            ReplacementTransform(rectangle70,text15)
        )

        self.play(rectangle8.animate().move_to([16, 5, 0]))
        
        text16 = Tex(
                   r"$f_{22}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text15,RIGHT,buff=1)
       
        self.play(Write(text16))




        text17 = Tex(
                   r"$\cdot \left( \dfrac{x}{-y^{2}}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text16,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(6*RIGHT))
        self.play(Write(text17))


        text18 = Tex(
                   r"$+f_{21}$"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text17,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(10*RIGHT))
        self.play(Write(text18))



        text19 = Tex(
                   r"$\cdot \left( \dfrac{1}{x}\right) $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text18,RIGHT,buff=1)
        self.play(rectangle8.animate().shift(5*RIGHT))
        self.play(Write(text19))
        self.wait(0.3)
        text20 = Tex(
                   r"$\dfrac{\partial ^{2}g}{\partial x\partial y}=1-\left[ \dfrac{y}{-x^{3}}f_{11}+\dfrac{2}{xy}f_{12}-\dfrac{x}{y^{3}}f_{22}-\dfrac{1}{x^{2}}f_{1}-\dfrac{1}{y^{2}}f_{2}\right] $"
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])

        self.play(
            ReplacementTransform(rectangle9,text20),
            ReplacementTransform(rectangle8,text20),
            ReplacementTransform(rectangle5,text20),
            ReplacementTransform(rectangle6,text20),
            ReplacementTransform(rectangle7,text20),
            ReplacementTransform(text19,text20),
            ReplacementTransform(text18,text20),
            ReplacementTransform(text17,text20),
            ReplacementTransform(text16,text20),
            ReplacementTransform(text15,text20),
            ReplacementTransform(text14,text20),
            ReplacementTransform(text13,text20),
            ReplacementTransform(text12,text20),
            ReplacementTransform(text11,text20),
            ReplacementTransform(text10,text20),
            ReplacementTransform(text9,text20),
            ReplacementTransform(text8,text20),
            ReplacementTransform(text7,text20),
            ReplacementTransform(text6,text20),
            ReplacementTransform(text140,text20)
            
        )

        text21 = Tex(
                   r"$2xy\dfrac{\partial ^{2}g}{\partial x\partial y}=2xy+\dfrac{2y^{2}}{x^{2}}f_{11}-4f_{12}+\dfrac{2x^{2}}{y^{2}}f_{22}+\dfrac{2y}{x}f_{1}+\dfrac{2x}{y}f_{2}$",color=YELLOW
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-25,0])

        self.play(Write(text21))
        
        self.play(FadeOut(text20)) 
        

        self.play(Restore(self.camera.frame))

        text22 = Tex(
                   r"$y^{2}\dfrac{\partial ^{2}g}{\partial y^{2}}=-\dfrac{x^{2}}{y^{2}}f_{22}+2f_{21}-\dfrac{y^{2}}{x^{2}}f_{11}-\dfrac{2x}{y}f_{2}$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])

        self.play(Write(text22))

        arrow = Arrow(start=[-9,-9,0],end=[-9,-11,0],color=GREEN
                       , stroke_width=40, tip_length=3)
        arrow1 = Arrow(start=[-5,-9,0],end=[-5,-11,0],color=WHITE
                       , stroke_width=40, tip_length=3)
        arrow2 = Arrow(start=[2,-9,0],end=[2,-11,0],color=WHITE
                       , stroke_width=40, tip_length=3)
        arrow3 = Arrow(start=[9.5,-9,0],end=[9.5,-11,0],color=GREEN
                       , stroke_width=40, tip_length=3)
        arrow4 = Arrow(start=[12.5,-9,0],end=[12.5,-11,0],color=WHITE
                       , stroke_width=40, tip_length=3)
        arrow5 = Arrow(start=[19,-9,0],end=[19,-11,0],color=GREEN
                       , stroke_width=40, tip_length=3)
        arrow6 = Arrow(start=[21,-9,0],end=[21,-11,0],color=WHITE
                       , stroke_width=40, tip_length=3)
        
        self.play(self.camera.frame.animate.scale(0.5).move_to([0,-10,0]))
        

        self.play(GrowArrow(arrow),GrowArrow(arrow3),GrowArrow(arrow5))
        self.play(GrowArrow(arrow1),GrowArrow(arrow2),GrowArrow(arrow4),GrowArrow(arrow6))

        self.play(FadeOut(arrow1),FadeOut(arrow2),FadeOut(arrow4),FadeOut(arrow6)
                  ,FadeOut(arrow),FadeOut(arrow3),FadeOut(arrow5),Restore(self.camera.frame))
        
        text23 = Tex(
                   r"$y^{2}\dfrac{\partial ^{2}g}{\partial y^{2}}=-\dfrac{y^{2}}{x^{2}}f_{11}+2f_{12}-\dfrac{x^{2}}{y^{2}}f_{22}-\dfrac{2x}{y}f_{2}$",color=BLUE
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).move_to([0,-15,0])

        self.play(
            ReplacementTransform(text22,text23)
        )
        self.wait(0.5)

        rectangle10=Rectangle(color=BLUE,fill_opacity=0.0,width=6.2,height=9
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle10.move_to([-6.9, -5, 0])
        rectangle11=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle11.move_to([-7, -15, 0])
        rectangle12=Rectangle(color=BLUE,fill_opacity=0.0,width=7,height=8
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle12.move_to([-8, -24.5, 0])
        self.play(Create(rectangle10),Create(rectangle11),Create(rectangle12))
        #######
        rectangle13=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle13.move_to([2.5, -5, 0])
        rectangle14=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle14.move_to([2.5, -15, 0])
        rectangle15=Rectangle(color=BLUE,fill_opacity=0.0,width=7,height=8
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle15.move_to([2, -24.5, 0])
        self.play(Create(rectangle13),Create(rectangle14),Create(rectangle15))
        ########
        rectangle16=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle16.move_to([10, -5, 0])
        rectangle17=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle17.move_to([10, -15, 0])
        rectangle18=Rectangle(color=BLUE,fill_opacity=0.0,width=7,height=8
                            ,stroke_color=GREEN,stroke_width=20)
        rectangle18.move_to([10, -24.5, 0])
        self.play(Create(rectangle16),Create(rectangle17),Create(rectangle18))
        ########
        rectangle19=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle19.move_to([20, -5, 0])
        rectangle20=Rectangle(color=BLUE,fill_opacity=0.0,width=6,height=9
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle20.move_to([20, -15, 0])
        rectangle21=Rectangle(color=BLUE,fill_opacity=0.0,width=12,height=8
                            ,stroke_color=WHITE,stroke_width=20)
        rectangle21.move_to([25, -24.5, 0])
        self.play(Create(rectangle19),Create(rectangle20),Create(rectangle21))

        rectangle22=Rectangle(color=BLUE,fill_opacity=0.0,width=5,height=8
                            ,stroke_color=PURE_RED,stroke_width=20)
        rectangle22.move_to([-17.5, -24.5, 0])
        self.play(Create(rectangle22))
        self.wait(0.3)
        text24 = Tex(
                   r"$=2xy$",color=PURE_RED
                   ,tex_template=TexTemplateLibrary.ctex).scale(5.0).next_to(text1,RIGHT,buff=3)
        self.play(
            ReplacementTransform(rectangle22,text24)
        )



        self.wait(0.5)
        self.wait()